package org.zjt.servlet3;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.annotation.WebListener;
import java.util.Arrays;

/**
 * DESC
 *
 * @author
 * @create 2017-07-17 下午4:48
 **/
@WebListener
public class MyServletRequsetListener implements ServletRequestListener {

    @Override
    public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        servletRequestEvent.getServletRequest().getParameterMap().forEach((k, v) ->servletRequestEvent.getServletContext().log("Request监听器:"+k + "  " + String.valueOf(Arrays.stream(v).reduce(new String(), (a, b) -> b + "," + a, (a, b) -> b + a))));
        servletRequestEvent.getServletContext().log("产生request请求");
    }

    @Override
    public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
        servletRequestEvent.getServletRequest().getParameterMap().forEach((k, v) -> servletRequestEvent.getServletContext().log("Request监听器:"+k + "  " + String.valueOf(Arrays.stream(v).reduce(new String(), (a, b) -> b + "," + a, (a, b) -> b + a))));
        servletRequestEvent.getServletContext().log("结束request请求");
    }


}
